﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufComboBoxButton.h"
#include "WeakReferenceable.h"

namespace gnuf
{
    class DropDownBoard;
}

namespace gnuf {

    /* The CommonLineStyleButtonModel class defined the strategy that a CommonLineStyleButton instance used to represent the line style pixmap icon.
    Here is only a virtual interface and can not be instantiated, the implementations of the class depends on BuNewUiFrameworkExtension module, where
    three derived class named LineStyleButtonModel, LinePatternButtonModel, LineWidthButtonModel were defined to show different line types with gcmp data
    source respectively*/

    class GNUF_BASE_EXPORT CommonLineStyleButtonModel
        : public gcmp::WeakReferenceable
    {
        friend class CommonLineStyleButton;
    protected:
        virtual bool isValid() { return true; }
        virtual void onPaintLineStyleItems(DropDownBoard*) = 0;
    };

    class GNUF_BASE_EXPORT CommonLineStyleButton
        : public ComboBoxButton
    {
    public:
        static const EItemType Type;

        explicit CommonLineStyleButton(Item* parent);
        virtual ~CommonLineStyleButton() {}

        void setModel(CommonLineStyleButtonModel* model);
    protected:
        virtual void onSelectionChanged(bool) override {}

        gcmp::WeakPtr<CommonLineStyleButtonModel> m_model;
    };
}
